CONSTSTR MYRTLEXP CVT_G2CoordsStr( char *buff, size_t bsz,
                                   const GCoord_t& x, const GCoord_t& y,
                                   PMVProjectionInfo pr, Coordinate_Type cs, int dn, degTypes dt, char *dlm )
  {  Coordinate_Tuple sgc;
     Parameter_Tuple  sgp;

     sgp.Equidistant_Cylindrical.std_parallel     = 1;
     sgp.Equidistant_Cylindrical.central_meridian = 0;
     sgp.Equidistant_Cylindrical.false_easting    = 0;
     sgp.Equidistant_Cylindrical.false_northing   = 0;

     sgc.Equidistant_Cylindrical.easting = x;
     sgc.Equidistant_Cylindrical.northing = y;

 return CVT_Coord2Str( buff, bsz,
                       sgc, sgp, SYS_COORDSYS, SYS_DATUM,
                       pr, cs, dn, dt, dlm );
}

bool MYRTLEXP CVT_LatLon2G( double x, double y, int dn, PMVProjectionInfo pr, GPoint& gp )
  {
     gp.x = Max( MIX_G_X, Min(x, MAX_G_X) );
     gp.y = Max( MIX_G_Y, Min(y, MAX_G_Y) );

     Coordinate_Tuple sgc;
     Parameter_Tuple  sgp;
     Coordinate_Tuple dgc;
     Parameter_Tuple  dgp;

     sgp.Geodetic.height_type = No_Height;

     sgc.Geodetic.longitude = G2Rad(x);
     sgc.Geodetic.latitude  = G2Rad(y);

     dgp.Equidistant_Cylindrical.std_parallel     = 1;
     dgp.Equidistant_Cylindrical.central_meridian = 0;
     dgp.Equidistant_Cylindrical.false_easting    = 0;
     dgp.Equidistant_Cylindrical.false_northing   = 0;

     if ( !CVT_Coord2Coord( sgc, sgp, Geodetic, dn, dgc, dgp, SYS_COORDSYS, SYS_DATUM ) )
       return false;

     gp.x = dgc.Equidistant_Cylindrical.easting;
     gp.y = dgc.Equidistant_Cylindrical.northing;

 return true;
}

bool MYRTLEXP CVT_G2LatLon( const GPoint& p, int dn, PMVProjectionInfo pr, double& x, double& y )
  {
     Coordinate_Tuple sgc;
     Parameter_Tuple  sgp;
     Coordinate_Tuple dgc;
     Parameter_Tuple  dgp;

     sgc.Equidistant_Cylindrical.easting  = Max( MIX_G_X, Min(p.x, MAX_G_X) );
     sgc.Equidistant_Cylindrical.northing = Max( MIX_G_Y, Min(p.y, MAX_G_Y) );

     sgp.Equidistant_Cylindrical.std_parallel     = 1;
     sgp.Equidistant_Cylindrical.central_meridian = 0;
     sgp.Equidistant_Cylindrical.false_easting    = 0;
     sgp.Equidistant_Cylindrical.false_northing   = 0;

     dgp.Geodetic.height_type = No_Height;

     if ( !CVT_Coord2Coord( sgc, sgp, SYS_COORDSYS, SYS_DATUM, dgc, dgp, Geodetic, dn ) )
       return false;

     x = Rad2G( dgc.Geodetic.longitude );
     y = Rad2G( dgc.Geodetic.latitude );

 return true;
}

//---------------------------------------------------------------------------
bool MYRTLEXP CVT_Any2G( const OZIMapPoint& op, Coordinate_Type cs, int dn, PMVProjectionInfo pr, GPoint& gp )
  {
     if ( ((int)cs) < 0 || cs >= ARRAY_SIZE(Conversions) ) {
       SetError( LNG("Unknown coordinate system %d"), cs );
       return false;
     }

     PAnyConversion p = &Conversions[cs];
     if ( !p->GetC ) {
       SetError( LNG("Conversion using %s coordinate system is not supported"), GD_CoordName(cs) );
       return false;
     }
     if ( p->isLatLon != op.isLatLon ) {
       if ( p->isLatLon )
         SetError( LNG("Coordinates must be in Lat/Lon form") );
        else
         SetError( LNG("Coordinates must be in N/E form") );
       return false;
     }

     Coordinate_Tuple dgc;
     Parameter_Tuple  dgp;
     Coordinate_Tuple sgc;
     Parameter_Tuple  sgp;

     if ( p->FillP )
       p->FillP( pr, sgp );

     p->SetC( op, sgc );

     dgp.Equidistant_Cylindrical.std_parallel     = 1;
     dgp.Equidistant_Cylindrical.central_meridian = 0;
     dgp.Equidistant_Cylindrical.false_easting    = 0;
     dgp.Equidistant_Cylindrical.false_northing   = 0;

     if ( !CVT_Coord2Coord( sgc, sgp, cs, dn, dgc, dgp, SYS_COORDSYS, SYS_DATUM ) )
       return false;

     gp.x = dgc.Equidistant_Cylindrical.easting;
     gp.y = dgc.Equidistant_Cylindrical.northing;

 return true;
}

bool MYRTLEXP CVT_G2Any( const GPoint& gp, Coordinate_Type cs, int dn, PMVProjectionInfo pr, OZIMapPoint& op )
  {
     if ( ((int)cs) < 0 || cs >= ARRAY_SIZE(Conversions) ) {
       SetError( LNG("Unknown coordinate system %d"), cs );
       return false;
     }

     PAnyConversion p = &Conversions[cs];
     if ( !p->GetC ) {
       SetError( LNG("Conversion using %s coordinate system is not supported"), GD_CoordName(cs) );
       return false;
     }

     op.isLatLon = p->isLatLon;

     Coordinate_Tuple dgc;
     Parameter_Tuple  dgp;
     Coordinate_Tuple sgc;
     Parameter_Tuple  sgp;

     sgc.Equidistant_Cylindrical.easting = gp.x;
     sgc.Equidistant_Cylindrical.northing = gp.y;

     sgp.Equidistant_Cylindrical.std_parallel     = 1;
     sgp.Equidistant_Cylindrical.central_meridian = 0;
     sgp.Equidistant_Cylindrical.false_easting    = 0;
     sgp.Equidistant_Cylindrical.false_northing   = 0;

     if ( p->FillP )
       p->FillP( pr, dgp );

     if ( !CVT_Coord2Coord( sgc, sgp, SYS_COORDSYS, SYS_DATUM, dgc, dgp, cs, dn ) )
       return false;

     p->GetC( dgc, op );

 return true;
}
